<?php
	if ($_POST['name']){
		$name = $_POST['name'];
		setcookie("name", $name);
		if ($_POST['email']){
			setcookie('email', $_POST['email']);
			if ($_POST['password']){
				header('Location: register.php');
				// echo "$name, регистрация прошла успешно!";
			}else{
				$error = "пароль";
			}
		}else{
			$error = "Email";
		}
	}else{
		$error = "Имя";
	}
	
?>
<!DOCTYPE html>
<html lang="ru">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>6 задание</title>
	<link rel="stylesheet" href="../css/style.css">
	<link rel="shortcut icon" href="https://media04.lokalkompass.de/article/2017/07/25/3/9561933_XXL.jpg">
</head>
<body>
	<div class="header-wraper">
		<div class="header">
			<a href="/" class="logo-link">
				<img src="../css/s2.png" alt="logo" class="logo-img">
				<p class="logo-text">На главную</p>
			</a>
		</div>
	</div>
	<div class="content-wraper">
		<div class="content">
			<h1 class="title">Регистрация</h1>
			<form action="#" method="POST" class="register-form">
				<span>Имя:</span>
				<input type="text" name="name" class="input-text" value=<?echo '"'.$_COOKIE['name'].'"';?>><br>
				<span>Email:</span>
				<input type="email" name="email" class="input-text" value=<?echo '"'.$_COOKIE['email'].'"';?>><br>
				<span>Пароль:</span>
				<input type="password" name="password" class="input-text"><br>
				<button type="submit" class="butsub">Регистрация</button>
				<span class="register_error"><?php if ($error){
					echo "Заполните поле $error!";
				} ?></span>
			</form>
		</div>
	</div>
</body>
</html>
